package com.dex4d.ui.mine.activity;

import android.widget.TextView;

import com.dex4d.R;
import com.dex4d.dialog.CommonMessageDialog;
import com.dex4d.dialog.CustomDialog;
import com.dex4d.model.User;
import com.dex4d.ui.wallet.activity.PinActivity;
import com.dex4d.utils.Commons;

import butterknife.BindView;

/**
 * Created by chengyuchun on 2018/11/5.
 */
public class CheckPinActivity extends PinActivity {
    @BindView(R.id.tv_pin_title)
    TextView mTvPinTitle;

    @Override
    protected void initToolbar() {
        super.initToolbar();
        mTvPinTitle.setText(getString(R.string.input_your_pin));
    }

    @Override
    protected void operatePins() {
        String checkPins = getPins();
        String pins = User.getInstance().getPinCode();
        String toTarget = getIntent().getStringExtra(Commons.BUNDLE_KEYS.TO_TARGET);
        if(pins.equals(checkPins)){
            if(TO_MNEMONIC.equals(toTarget)){
                openActivity(ExportMnemonicActivity.class);
                finish();
            }else if(TO_KEYSTORE.equals(toTarget)){
                openActivity(PasswordKeystoreActivity.class);
                finish();
            }

        }else {
            CommonMessageDialog dialog = new CommonMessageDialog(this,CommonMessageDialog.DialogStyle.TIP);
            dialog.setMsg(getString(R.string.pin_error));
            dialog.setLeftBtnTxt(getString(R.string.ok));
            dialog.setClickListener(new CustomDialog.CustomDialogOnClickListener() {
                @Override
                public void click(boolean flag) {
                    if (!flag) {
                    }
                }
            });
            dialog.show();
        }
    }
}
